<script setup>
import {RouterLink, RouterView} from 'vue-router';
import {getCurrentInstance, h, ref} from 'vue';
import {notification} from "ant-design-vue";
import {SmileOutlined} from "@ant-design/icons-vue";

const currentBranch = ref('两块五');
const response = ref('');
const {proxy, ctx} = getCurrentInstance();

function truncate(values) {
  try {
    // proxy.$api.get('/data/demo01', {id: '123'}).then((res) => {
    //   console.log(res);
    //   console.log(res.name);
    //   msessage.success();
    // });
    notification.open({
      message: '登录成功',
      description: '欢迎业主' + values + ' 回家~! 为业主保驾护航！！',
      icon: () => h(SmileOutlined, {style: 'color: #108ee9'})
    });
  } catch (error) {
    console.error(error);
  }
}

const userInfo = ref([
  {
    id: '1',
    title: '西瓜老板',
    path: '/',
    children: [{
      id: '1_1',
      title: '西瓜老板-（审批）',
      path: '/aprv_data'
    }]
  },
  {
    id: '2',
    title: '菠萝老板',
    path: '/user_data',
    children: [{
      id: '2_1',
      title: '菠萝老板-（示例数据）',
      path: '/user_data'
    }]
  }
]);
</script>

<template>
  <a-layout style="width: 1680px; height: 800px; margin: -200px -200px -200px -200px">
    <a-layout-header class="header">
      <div class="logo"/>
      <a-menu
          v-model:selectedKeys="selectedKeys1"
          theme="dark"
          mode="horizontal"
          :style="{ lineHeight: '64px' }"
      >
        <a-menu-item key="1">nav 1</a-menu-item>
      </a-menu>
    </a-layout-header>
    <a-layout-content style="padding: 0 50px">
      <a-breadcrumb style="margin: 16px 0">
        <a-breadcrumb-item>Home</a-breadcrumb-item>
        <a-breadcrumb-item>List</a-breadcrumb-item>
        <a-breadcrumb-item>App</a-breadcrumb-item>
      </a-breadcrumb>
      <a-layout style="padding: 24px 0; background: #fff">
        <a-layout-sider width="200" style="background: #fff">
          <a-menu
              v-model:selectedKeys="selectedKeys2"
              v-model:openKeys="openKeys"
              mode="inline"
              style="height: 100%"
          >
            <a-list v-for="item in userInfo">
              <a-sub-menu :key="item.title">
                <template #title>
                <span>
                  <user-outlined/>
                {{ item.title }}
                </span>
                </template>
                <a-list v-for="childrenItem in item.children">
                  <a-menu-item :key="childrenItem.index" >
                    <RouterLink :to="childrenItem.path">{{ childrenItem.title }}</RouterLink>
                  </a-menu-item>
                </a-list>
              </a-sub-menu>
            </a-list>
          </a-menu>
        </a-layout-sider>
        <a-layout-content :style="{ padding: '0 24px', minHeight: '280px' }">
          <RouterView/>
        </a-layout-content>
      </a-layout>
    </a-layout-content>
    <a-layout-footer style="text-align: center">
      Ant Design ©2018 Created by Ant UED
    </a-layout-footer>
  </a-layout>
</template>


<style scoped>
html, body, #app {
  height: 100%;
  margin: 0;
  padding: 0;
}

#app {
  margin: 0 0;
}

header {
  line-height: 1.5;
  max-height: 1000vh;
}

.logo {
  display: block;
  margin: 0 auto 2rem;
}

nav {
  width: 100%;
  font-size: 12px;
  text-align: center;
  margin-top: 2rem;
}

nav a.router-link-exact-active {
  color: var(--color-text);
}

nav a.router-link-exact-active:hover {
  background-color: transparent;
}

nav a {
  display: inline-block;
  padding: 0 1rem;
  border-left: 1px solid var(--color-border);
}

nav a:first-of-type {
  border: 0;
}

@media (min-width: 1480px) {
  header {
    display: flex;
    place-items: center;
    padding-right: calc(var(--section-gap) / 2);
  }

  .logo {
    margin: 0 2rem 0 0;
  }

  header .wrapper {
    display: flex;
    place-items: flex-start;
    flex-wrap: wrap;
  }

  nav {
    text-align: left;
    margin-left: -1rem;
    font-size: 1rem;

    padding: 1rem 0;
    margin-top: 1rem;
  }
}

#components-layout-demo-top-side .logo {
  float: left;
  width: 120px;
  height: 31px;
  margin: 16px 24px 16px 0;
  background: rgba(255, 255, 255, 0.3);
}

.ant-row-rtl #components-layout-demo-top-side .logo {
  float: right;
  margin: 16px 0 16px 24px;
}

.site-layout-background {
  background: #fff;
}

.size {
  width: 100%;
  height: 100%;
}
</style>
